Dynomotion

Group: DynoMotion Message: 9722 From: Sam Marrocco Date: 6/27/2014
Subject: Interpreter.Interpret() re-reading emc.var file
Although I don't need any of the values within, I have included the emc.var file in my vb.net executable's app path because it is required at Interpreter initialization. I then set my desired startup values with Interpreter.SetupParams.foo=bar.

However, it appears that the first time Interpreter.Interpret is actually called, it again reads the emc.var file and changes the SetupParams variables, defeating anything changed with Interpreter.SetupParams programmatically.

Can you verify this?

It seems that the file should only be read at initialization...?

--

sam marrocco | chief technical officer
ringside.cutters.picnic.moonlink

248 548 2500 w
248 910 3344 c

ringsidecreative.com

Group: DynoMotion Message: 9738 From: Tom Kerekes Date: 6/29/2014
Subject: Re: Interpreter.Interpret() re-reading emc.var file
Hi Sam,

When you call the Interpreter's Interpret function there is a parameter called Restart.  Setting that parameter will cause the Interpreter to re-initialize otherwise it should not re-load the settings.

Regards
TK

Group: DynoMotion Message: 9739 From: Sam Marrocco Date: 6/29/2014
Subject: Re: Interpreter.Interpret() re-reading emc.var file
On 6/29/2014 5:04 PM, Tom Kerekes tk@... [DynoMotion] wrote:
 
Hi Sam,

When you call the Interpreter's Interpret function there is a parameter called Restart.  Setting that parameter will cause the Interpreter to re-initialize otherwise it should not re-load the settings.



I am only using the Interpret() method with filename--not with the restart option so shouldn't that prevent reloading entirely?

In an attempt to fix this, I noticed that I had not flashed the KMotion firmware with the new 4.33c. I did so. After updating all the dlls and prerequisites, now I am seeing the Interpreter_Completed event return with and err of "Bad setup file format" nay time I execute a gcode file. I had copied over my default emc.var file with the new 4.33c's software folder but can't seem to track down this error. Any suggestions?

--

sam marrocco | chief technical officer
ringside.cutters.picnic.moonlink

248 548 2500 w
248 910 3344 c

ringsidecreative.com

Group: DynoMotion Message: 9740 From: Tom Kerekes Date: 6/29/2014
Subject: Re: Interpreter.Interpret() re-reading emc.var file
Hi Sam,

There is an initalization function in the Interpreter called

InitializeInterpreter()

This initializes the interpreter including reading the Settings and Variables.  This is what the Restart Option calls.  To ensure the interpreter is at least initialized once the Interpreter also has a flag called m_InitializeOnExecute that is set until the Interpreter is initialized.  If the Interpreter has never been initialized a call to InitializeInterpreter() will be made on the first Execution regardless of the Restart Option parameter.

I suppose you are trying to override the normal Initialization process.  In that case you might call InitializeInterpreter() before doing your overrides.

You can also query the flag with Get_InitializeOnExecute()


Regarding "Bad setup file format": that would normally indicate the Setup File Format is bad.  The expected format is any number of lines of "Header", followed by a blank line, followed by the attribute lines.  The interpreter may be picky about the blank line.  It should be a new line character only.  You might try using one of our example Setup Files to see if it also causes an error.  Or step through the function read_setup_file() to see exactly what the problem is.

HTH
Regards
TK



From: "Sam Marrocco SMarrocco@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Sunday, June 29, 2014 6:53 PM
Subject: Re: [DynoMotion] Interpreter.Interpret() re-reading emc.var file

 
On 6/29/2014 5:04 PM, Tom Kerekes tk@... [DynoMotion] wrote:
 
Hi Sam,

When you call the Interpreter's Interpret function there is a parameter called Restart.  Setting that parameter will cause the Interpreter to re-initialize otherwise it should not re-load the settings.



I am only using the Interpret() method with filename--not with the restart option so shouldn't that prevent reloading entirely?

In an attempt to fix this, I noticed that I had not flashed the KMotion firmware with the new 4.33c. I did so. After updating all the dlls and prerequisites, now I am seeing the Interpreter_Completed event return with and err of "Bad setup file format" nay time I execute a gcode file. I had copied over my default emc.var file with the new 4.33c's software folder but can't seem to track down this error. Any suggestions?

--

sam marrocco | chief technical officer
ringside.cutters.picnic.moonlink

248 548 2500 w
248 910 3344 c

ringsidecreative.com



Group: DynoMotion Message: 9746 From: Sam Marrocco Date: 6/30/2014
Subject: Re: Interpreter.Interpret() re-reading emc.var file

On 6/29/2014 11:07 PM, Tom Kerekes tk@... [DynoMotion] wrote:
 
Hi Sam,

There is an initalization function in the Interpreter called

InitializeInterpreter()

This initializes the interpreter including reading the Settings and Variables.  This is what the Restart Option calls.  To ensure the interpreter is at least initialized once the Interpreter also has a flag called m_InitializeOnExecute that is set until the Interpreter is initialized.  If the Interpreter has never been initialized a call to InitializeInterpreter() will be made on the first Execution regardless of the Restart Option parameter.

I suppose you are trying to override the normal Initialization process.  In that case you might call InitializeInterpreter() before doing your overrides.

You can also query the flag with Get_InitializeOnExecute()


Regarding "Bad setup file format": that would normally indicate the Setup File Format is bad.  The expected format is any number of lines of "Header", followed by a blank line, followed by the attribute lines.  The interpreter may be picky about the blank line.  It should be a new line character only.  You might try using one of our example Setup Files to see if it also causes an error.  Or step through the function read_setup_file() to see exactly what the problem is.

HTH
Regards
TK




Got it. That explains why the first call to Interpret() reads the emc.var file, changing all my programmatically set values.
As a workaround I was doing this:

Interpreter.VarsFile=blah 'file just set as a requirement even though it doesn't contain anything being used.
Set my motion params here.
Set my Tuning params here.
Run any GCode, forcing the Interpreter to load the emc.var file and reset it's params. Something like G4 P.1 ( very short dwell command).
Set my Interpreter.SetupParams to custom values programmatically.
Any GCode that is run now does not change the SetupParams.

....but the more proper way would be:

Interpreter.VarsFile=blah 'file just set as a requirement even though it doesn't contain anything being used.
Set my motion params here.
Set my Tuning params here.
Interpreter.InitializeInterpreter() 'Forces first read of emc.var file.
Set my Interpreter.SetupParams to custom values programmatically.
Any GCode that is run now does not change the SetupParams.

....and that looks like it's working. Thanks!

sam marrocco | chief technical officer
ringside.cutters.picnic.moonlink

248 548 2500 w
248 910 3344 c

ringsidecreative.com

Group: DynoMotion Message: 11941 From: baltar.chris Date: 7/22/2015
Subject: Re: Interpreter.Interpret() re-reading emc.var file
This is great!  Thank you Tom!

-Chris